#ifndef FIREWORKBASE_H
#define FIREWORKBASE_H

#include <memory>
#include <random>

#include "FireworkParticle.h"

enum class FireworkState {
	Flying,
	Blast,
	Done
};

class FireworkBase {
	public:
		FireworkBase(Vector3 pos, float speed) : m_pos{pos}, z_speed{speed} {
			std::random_device rd;  // 将用于获得随机数引擎的种子
			m_gen = std::mt19937_64(rd()); // 以 rd() 播种的标准 mersenne_twister_engine
		}
		~FireworkBase() {};

		void update(const std::chrono::nanoseconds& delt);
		void draw();

		void setRaiseBgm(std::shared_ptr<Sound> bgm) {
			m_raiseBgm = bgm;
		}

		void setBombBgm(std::shared_ptr<Sound> bgm) {
			m_bombBgm = bgm;
		}

		bool isDone() {
			return m_state == FireworkState::Done;
		};
		
		void activate();

	protected:
		void addNewBombs(Vector3 pos, const std::vector<Vector3>& speedList, Color color, uint8_t lengthBomb);
		virtual void initFireworkParticles() = 0;

	private:
		void setBombsMovePara(const std::vector<std::shared_ptr<FireworkParticle>>& newBombs);

	protected:
		std::vector<std::shared_ptr<FireworkParticle>> m_fireworkParticles;
		Vector3 m_pos;
		std::mt19937_64 m_gen;

	private:
		FireworkState m_state{FireworkState::Flying};
		std::shared_ptr<Sound> m_raiseBgm, m_bombBgm;
		float z_speed;
};

#endif
